using Refit;
using Zhaoxi.MSACommerce.HttpApi.Common;
using ZhaoXi.MSACommerce.Authentication.JwtBearer;
using ZhaoXi.MSACommerce.Infrastructure.EnityFrameworkCore;
using ZhaoXi.MSACommerce.UserService.HttpApi;
using ZhaoXi.MSACommerce.UserService.HttpApi.Servcie;
using ZhaoXi.MSACommerce.UserService.Infrastructure;
using ZhaoXi.MSACommerce.UserService.UserCases;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddInfrastructure(builder.Configuration);

builder.Services.AddUseCase();

builder.Services.AddHttpApi();
builder.Services.AddRefitClient<IVerificationService>()
    .ConfigureHttpClient(client =>
    {
        client.BaseAddress = new Uri("http://localhost:5043"); 
        client.Timeout = TimeSpan.FromSeconds(30);
    });
builder.Services.AddControllers();
builder.Services.AddJwtBearer(builder.Configuration);

// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

app.UseHttpsRedirection();

app.UseHttpCommon();

app.MapControllers();

app.Run();
